package org.ariadne_eu.hcifetcher.rest;

import java.util.Comparator;

import org.ariadne_eu.hcifetcher.util.DateManager;
import org.joda.time.DateTime;
import org.json.JSONException;
import org.json.JSONObject;


public class EntryDateComparator implements Comparator<JSONObject> {

	@Override
	public int compare(JSONObject o1, JSONObject o2) {
		try {
			DateTime date1 = DateManager.fmt1.parseDateTime((String)o1.get("datestamp"));
			DateTime date2 = DateManager.fmt1.parseDateTime((String)o2.get("datestamp"));
			return date1.compareTo(date2) * -1;
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();	
		}
		return 0;
	}
	



}
